<%@ page language="java"   contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.ex.fileupdown.fileboard.dao.FileBoardDaoImpl"%>
<%@page import="com.ex.fileupdown.fileboard.dao.FileBoardDao"%>
<%@page import="com.ex.fileupdown.vo.FileBoardVO"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.ex.fileupdown.notice.dao.BoardDaoImpl"%>
<%@page import="com.ex.fileupdown.notice.dao.BoardDao"%>
<%@ include file="/includes.jsp"%>
<%@ page import="java.sql.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script type="text/javascript">
<%
String curPage = request.getParameter("curPage");
String maxRow = request.getParameter("maxRow");
System.out.println("curpage value = " + curPage);

FileBoardDao dao = new FileBoardDaoImpl();
List<FileBoardVO> dataList = dao.select(curPage, maxRow, "");
int totalCnt = dataList.get(0).getTotalCount();

%>
$(document).ready(function() {
	var curPage = <%= curPage%>;
	var maxRow = <%= maxRow%>;
	var totalCnt = <%= totalCnt%>;
	
	$("#curPage").val(curPage);
	$("#maxRow").val(maxRow);
	$("#totalCnt").val(totalCnt);
	
	fnc_setPaging(totalCnt,maxRow,curPage);
});

	$(document).on("click",'.searchPage',function() {
	    var curPage = parseInt($("#curPage").val());
	    var maxRow  = parseInt($("#maxRow").val());
	    var text    = $(this).text().replace(/\s/g,'');
	    var id      = $(this).attr('id');
	    var thval 	= parseInt($(this).text());
	    $.ajax({
	        type	  : "POST",
	        url		  : "",
	        dataType  :"html",
	        async     : false,
	        data:{
	        	
	        },
	        success: function(dataList) {
	    		
	    	    if( id == "next"){
	    	        $("#curPage").val(curPage+1);
	    	    }else if(id == "end"){
	    	        $("#curPage").val(curPage+maxRow);
	    	    }else if(id == "prev"){
	    	        $("#curPage").val(curPage-1);
	    	    }else if(id == "first"){
	    	        $("#curPage").val(curPage-maxRow);
	    	    }else{
	    	        $("#curPage").val(thval);
	    	    }
	    	    
	    	    window.location.href="fileboardList.jsp?curPage="+$("#curPage").val()+"&maxRow="+$("#maxRow").val()+"&iTotalCount="+$("#totalCnt").val();
	        },
	        error: function(xhr, status, error){
	        	alert("에러발생");
	        }
	    });
	});

	

</script>
<head>
<title>board</title>
</head>
<body>
<form id="frm" name="frm">
<input type="text" id="curPage" name="curPage" value="${curPage}"/>
<input type="text" id="maxRow"  name="maxRow"  value="${maxRow}"/>
<input type="text" id="totalCnt"  name="totalCnt"  value="${totalCnt}"/>
<div>
	<%@ include file="/views/defaultLayout/top.jsp"%>
</div>
<table border="1">
	<tr bgcolor="gray">
		<td>번호</td>
		<td>제목</td>
		<td>작성자</td>
		<td>날짜</td>
		<td>첨부파일</td>
	</tr>
	
	<%for(int i=0; i<dataList.size() ; i++){%>
		<tr>
			<td><%=dataList.get(i).getBoardCd()%></td>
			<td><%=dataList.get(i).getTitle()%></td>
			<td><%=dataList.get(i).getWriterName()%></td>
			<td><%=dataList.get(i).getDate()%></td>
			<td>첨부파일</td>
		</tr>
	<% } %>	
		
	<tr>
		<td>
			<div class="pg1" id="pg1"></div>
		</td>
	</tr>
</table>
<div>
	<%@ include file="/views/defaultLayout/bottom.jsp"%>
</div>
</form>
</body>
</html>